#include <bits/stdc++.h>
// 2025/01/23
// tag: 
// Author: Zhang Muen
using namespace std;

int f[10001][3], x[10001];

int func(int x, int y){
    return f[x][0] * y * y + f[x][1] * y + f[x][2];
}

signed main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> f[i][0] >> f[i][1] >> f[i][2];
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    for (int i = 1; i <= n; i++)
        q.push(make_pair(func(i, 1), i)), x[i] = 1;
    int cnt = 0;
    while (cnt < m){
        auto p = q.top();
        q.pop();
        cout << p.first << " ";
        q.push(make_pair(func(p.second, ++x[p.second]), p.second));
        cnt++;
    }
    return 0;
}